<?php /* Smarty version 2.6.20, created on 2013-05-25 01:50:38
         compiled from _core/_include/common/pagination.tpl */ ?>
Pagination = function() {
};

Pagination.makePagedResults = function(container, page, total, limit, callBackFunc, context, doc) {
  if (!this._popupBox) {
    this._popupBox = new PopupBox();
  } else {
    this._popupBox._close();
  }

  page = parseInt(page, 10);
  total = parseInt(total, 10);
  limit = parseInt(limit, 10);

  var last;
  if (total == 0) {
    last = 1;
  } else {
    last = Math.ceil(total / limit);
    if (last == 0) {
      last = 1;
    }
  }

  if (total <= limit) {
    return;
  }

  var first = 1;
  var prev = ((page - 1) > 0) ? (page - 1) : 1;
  var next = ((page + 1) < last) ? (page + 1) : last;
  var lowRange = [];
  var highRange = [];
  var numRange = 5;
  var i, il, a;

  i = prev;
  while ((i > (prev - (numRange + 1))) && (i >= 1)) {
    lowRange[lowRange.length] = i;
    i--;
  }
  lowRange.reverse();

  i = next;
  while ((i < (next + (numRange + 1))) && (i <= last)) {
    highRange[highRange.length] = i;
    i++;
  }

  if (!doc) {
    doc = document;
  }

  var _self = this
  var func = function() {
      if (isNaN(this._page)) {
        window.alert('Not A Number');
        return;
      }
      if (this._page > last || this._page < 1) {
        window.alert('Exceeded The Range');
        return;
      }
      MiscUtils.load(_self._popupBox, DOMUtils.findPos(this), 'Loading...');
      callBackFunc(this._page);
      return false;
    };
  var r;
  var tr, td;
  var ltable = document.createElement('table');
  ltable.cellPadding = 0;
  ltable.cellSpacing = 0;
  ltable.style.height = '20px';
  ltable.style.margin = '0 0 5px 0';
  container.appendChild(ltable);
  
  ltr = ltable.insertRow(-1);
  ltd = ltr.insertCell(-1);
  ltd.style.textAlign = 'left';
  var itable = document.createElement('table');
  itable.cellPadding = 0;
  itable.cellSpacing = 0;
  itable.style.border = 'solid 1px #999';
  itable.style.backgroundColor = '#eae8e1';
  itable.style.height = '20px';
  itable.style.marginRight = '15px';
  var itr = itable.insertRow(-1);
  var itd = itr.insertCell(-1);
  var span1 = document.createElement('span');
  span1.style.fontSize = '12px';
  span1.style.fontWeight = 'bold';
  span1.style.padding = '0 0 0 5px';
  span1.appendChild(document.createTextNode(total));
  itd.appendChild(span1);
  
  var span2 = document.createElement('span');
  span2.style.fontWeight = 'bold';
  span2.style.fontSize = '110%';
  span2.style.color = '#694247';
  span2.appendChild(document.createTextNode(' Results in '));
  itd.appendChild(span2);
  
  var span3 = document.createElement('span');
  span3.style.fontSize = '12px';
  span3.style.fontWeight = 'bold';
  span3.appendChild(document.createTextNode(last));
  itd.appendChild(span3);
  ltd.appendChild(itable);
  
  var span4 = document.createElement('span');
  span4.style.fontWeight = 'bold';
  span4.style.fontSize = '110%';
  span4.style.color = '#694247';
  span4.style.padding = '0 5px 0 0';
  span4.appendChild(document.createTextNode(' Pages'));
  itd.appendChild(span4);
  ltd.appendChild(itable);
  
  ltd = ltr.insertCell(-1);
  ltd.style.width = '469px';
  ltd.style.textAlign = 'right';
  var contentTable = document.createElement('table');
  contentTable.cellPadding = 0;
  contentTable.cellSpacing = 0;
  ltd.appendChild(contentTable);
  tr = contentTable.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.verticalAlign = 'middle';
  var itable = document.createElement('table');
  itable.cellPadding = 0;
  itable.cellSpacing = 0;
  td.appendChild(itable);
  var itr = itable.insertRow(-1);
  var itd = itr.insertCell(-1);
  itd.style.width = '43px';
  var left = document.createElement('table');
  left.cellPadding = 0;
  left.cellSpacing = 0;
  left.style.height = '20px';
  itd.appendChild(left);
  if (prev > 0 && prev != page) {
    left.style.width = '43px';
    lftr = left.insertRow(-1);
    lftd = lftr.insertCell(-1);
    lftd.style.width = '20px';
    lftd.align = 'center';
    lftd._page = first;
    lftd.onclick = func;
    lftd.className= 'pagination';
    lftd.style.cursor = 'pointer';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/fh.png';
    lftd.appendChild(img);
    
    lftd = lftr.insertCell(-1);
    lftd.style.width = '3px';
    lftd.style.height = '20px';
    
    lftd = lftr.insertCell(-1);
    lftd.style.width = '20px';
    lftd.align = 'center';
    lftd.style.verticalAlign = 'middle';
    lftd.className= 'pagination';
    lftd.align = 'center';
    lftd._page = prev;
    lftd.onclick = func;
    lftd.style.cursor = 'pointer';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/rh.png';
    lftd.appendChild(img);
  } else {
    left.style.width = '45px';
    lftr = left.insertRow(-1);
    lftd = lftr.insertCell(-1);
    lftd.style.width = '20px';
    lftd.align = 'center';
    lftd.style.backgroundColor = '#fff';
    lftd.style.border = 'solid 1px #999';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/f.png';
    lftd.appendChild(img);
    
    lftd = lftr.insertCell(-1);
    lftd.style.width = '3px';
    lftd.style.height = '20px';
    
    lftd = lftr.insertCell(-1);
    lftd.style.width = '20px';
    lftd.align = 'center';
    lftd.style.verticalAlign = 'middle';
    lftd.style.backgroundColor = '#fff';
    lftd.style.border = 'solid 1px #999';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/r.png';
    lftd.appendChild(img);
  }
  itd = itr.insertCell(-1);
  itd.align = 'center';
  var middle = document.createElement('table');
  middle.style.width = '40px';
  middle.style.height = '20px';
  middle.style.paddingLeft = '3px';
  middle.cellPadding = 0;
  middle.cellSpacing = 0;
  itd.appendChild(middle);
  mtr = middle.insertRow(-1);
  mtd = mtr.insertCell(-1);
  for (i = 0, il = lowRange.length; i < il; i++) {
    r = lowRange[i];
    if (r != page) {
      var review = doc.createElement('review');
      review.style.height = '20px';
      review._page = r;
      review.onclick = func;
      review.className= 'pagination';
      review.align = 'center';
      review.style.cursor = 'pointer';
      review.style.padding = '2px 5px 1px';
      review.style.margin = '0 3px 0 0';
      review.appendChild(doc.createTextNode(r));
      mtd.appendChild(review);
    }
  }

  var strong = doc.createElement('strong');
  strong.style.height = '20px';
  strong.style.padding = '2px 5px 1px';
  strong.style.fontSize = '12px';
  strong.style.margin = '0 3px 0 0';
  strong.style.color = '#694247';
  strong.style.fontWeight = 'bold';
  strong.style.backgroundColor = '#fae5e5';
  strong.align = 'center';
  strong.style.border = 'solid 1px #694247';
  strong.appendChild(doc.createTextNode(page));
  mtd.appendChild(strong);
  
  for (i = 0, il = highRange.length; i < il; i++) {
    r = highRange[i];
    if (r != page) {
      next1 = doc.createElement('next1');
      next1.className= 'pagination';
      next1.style.height = '20px';
      next1.style.margin = '0 3px 0 0';
      next1.style.padding = '2px 5px 1px';
      next1.style.cursor = 'pointer';
      next1._page = r;
      next1.onclick = func;
      next1.appendChild(doc.createTextNode(r));
      mtd.appendChild(next1);
    }
  }
  
  itd = itr.insertCell(-1);
  itd.style.width = '43px';
  itd.align = 'center';
  itd.style.verticalAlign = 'middle';
  var right = document.createElement('table');
  right.cellPadding = 0;
  right.cellSpacing = 0;
  itd.appendChild(right);
  
  if (next > 0 && next != page) {
    right.style.width = '43px';
    rtr = right.insertRow(-1);
    rtd = rtr.insertCell(-1);
    rtd.style.width = '20px';
    rtd.align = 'center';
    rtd.className= 'pagination';
    rtd.style.verticalAlign = 'middle';
    rtd._page = next;
    rtd.onclick = func;
    rtd.style.cursor = 'pointer';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/nh.png';
    rtd.appendChild(img);
    
    rtd = rtr.insertCell(-1);
    rtd.style.width = '3px';
    rtd.style.height = '20px';
    
    rtd = rtr.insertCell(-1);
    rtd.style.width = '20px';
    rtd.align = 'center';
    rtd.style.verticalAlign = 'middle';
    rtd._page = last;
    rtd.onclick = func;
    rtd.style.cursor = 'pointer';
    rtd.className= 'pagination';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/lh.png';
    rtd.appendChild(img);
  } else {
    right.style.width = '43px';
    rtr = right.insertRow(-1);
    rtd = rtr.insertCell(-1);
    rtd.style.width = '20px';
    rtd.style.backgroundColor = '#fff';
    rtd.style.border = 'solid 1px #999';
    rtd.align = 'center';
    rtd.style.verticalAlign = 'middle';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/n.png';
    rtd.appendChild(img);
    
    rtd = rtr.insertCell(-1);
    rtd.style.width = '3px';
    rtd.style.height = '20px';
    
    rtd = rtr.insertCell(-1);
    rtd.style.width = '20px';
    rtd.style.backgroundColor = '#fff';
    rtd.style.border = 'solid 1px #999';
    rtd.align = 'center';
    rtd.style.verticalAlign = 'middle';
    var img = document.createElement('img');
    img.src = 'images/common/pagination/l.png';
    rtd.appendChild(img);
  }
  
  td = tr.insertCell(-1);
  td.style.paddingLeft = '15px';
  var itable = document.createElement('table');
  itable.cellPadding = 0;
  itable.cellSpacing = 0;
  td.appendChild(itable);
  itr = itable.insertRow(-1);
  itd = itr.insertCell(-1);
  itd.style.textAlign = 'left';
  itd.style.width = '39px';
  var pTxt = DOMUtils.createInput(null, null, 'text', '', null);
  pTxt.className = 'text';
  pTxt.style.width = '36px';
  pTxt.style.height = '16px';
  pTxt.style.textAlign = 'center';
  pTxt.style.border = 'solid 1px #999';
  pTxt.onkeypress = function() { itd._page = this.value; };
  pTxt.onchange = function() { itd._page = this.value; };
  itd.appendChild(pTxt);
  
  itd = itr.insertCell(-1);
  itd.style.width = '15px';
  itd.style.height = '15px';
  itd.style.padding = '0 5px';
  itd._page = page;
  itd.onclick = func;
  itd.style.fontSize = '9pt';
  itd.style.fontWeight = 'bold';
  itd.style.color = '#694247';
  itd.style.textAlign = 'center';
  itd.style.cursor = 'pointer';
  itd.className= 'pagination';
  itd.appendChild(doc.createTextNode('Go'));

};